#include "stacktest.h"

bool StackTest::run() {
	int count=0;

	if(!StackTest::pushPopTest())
		std::cout << "ERROR " << ++count << " StackTest::growTest() faild!" << std::endl;
	if(!StackTest::growTest())
		std::cout << "ERROR " << ++count << " StackTest::growTest() faild!" << std::endl;

	return count==0;
}

bool StackTest::pushPopTest() {
	Stack <int> myStack(10);
	myStack.push(6);
	myStack.push(99);
	myStack.push(3900);
	bool b = (myStack.pop()==3900);
	b=b && (myStack.pop()==99);
	b=b && (myStack.pop()==6);
	return b;
}

bool StackTest::growTest() {
	Stack <double> myStack(2);
	myStack.push(6);
	myStack.push(99);
	myStack.push(3900);
	myStack.push(78509);
	myStack.push(88888);
	bool b = (myStack.pop()==88888);
	b=b && (myStack.pop()==78509);
	b=b && (myStack.pop()==3900);
	b=b && (myStack.pop()==99);
	b=b && (myStack.pop()==6);
	return b;
}
